import QtQuick 2.0
import org.qtproject.znews_qt 1.0
import QtQuick.Controls 1.1
import "../common"
import "../delegate"

MainBasePage {

    id: idArticleImage

    m_header.title: "Hiện thị ảnh ..."
    m_header.showBack: true;
    m_header.onBackClicked: {
        console.log("Content Image : m_header.onBackClicked: ");
        previousPage();
    }

    visible: false

    color: "#000000"

    property string sourceImage;

    Flickable {
        id: flickable
        clip: true

        anchors.fill: parent


        y: m_header.height

        contentHeight: id_image.width
        contentWidth: id_image.width

        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenter: parent.verticalCenter

        Image {

            opacity: 1
            id: id_image
            source: sourceImage

            mirror: true

            anchors.horizontalCenter: parent.horizontalCenter
            anchors.verticalCenter: parent.verticalCenter

            visible: false

            onStatusChanged: {
                if (id_image.status == Image.Ready) {
                    id_image.visible = true;
                    id_waitingForm.visible = false;
                    //id_zoom.visible = true;
                }
            }

        }
    }

    ContentWaitingImage {
        id: id_waitingForm
        visible: true;
        width: parent.width
        height: 150 * ApplicationInfo.ratio

        anchors.horizontalCenter: parent.horizontalCenter
        anchors.verticalCenter: parent.verticalCenter
    }

//    ZoomControl {
//        id: id_zoom
//        x : parent.width - 40
//        y : 0
//        width : 100
//        height: parent.height

//        visible: false

//        currentZoom: 1.0
//        maximumZoom: 4
//        onZoomTo: {
//            id_zoom.currentZoom = id_zoom.currentZoom + 0.1;
//            id_image.scale = id_zoom.currentZoom;

//            flickable.contentHeight = id_image.height
//            flickable.contentWidth = id_image.width
//            flickable.y = m_header.height
//            id_image.Center = Image.Center
//        }

//    }


    Stack.onStatusChanged: {

        m_isLocked = !(Stack.status === Stack.Active)
        console.info("Stack onStatusChanged " , m_isLocked)

    }


}
